tutorials.de Buch-Aktion 05/2012
ERLEDIGT
NEIN
ANTWORTEN
2
ZUGRIFFE
1056
EMPFEHLEN
  • An Twitter übertragen
  • An Facebook übertragen
AUF DIESES THEMA
ANTWORTEN
  1. #1
    bigfish42 bigfish42 ist offline Grünschnabel
    Registriert seit
    Aug 2011
    Beiträge
    2
    Hallo bin Newbie ,bei dem script werden die Buchstaben untereinander bei Python Version 3.2
    und bei Python Version 2.5 nebeneinander ausgeben,was muss ich ändern um es auch der 3.2 version genauso hinzubekommen?

    for buchstabe in ['h','e','l','l','o',' ','w','o','r','l','d']:
    print (buchstabe),
     

  2. #2
    deepthroat deepthroat ist offline Mitglied Diamant
    tutorials.de Premium-User
    Registriert seit
    Jun 2005
    Beiträge
    8.168
    Hi.

    http://docs.python.org/release/3.0.1/whatsnew/3.0.html
    The print statement has been replaced with a print() function, with keyword arguments to replace most of the special syntax of the old print statement (PEP 3105). Examples:

    Old: print "The answer is", 2*2
    New: print("The answer is", 2*2)

    Old: print x, # Trailing comma suppresses newline
    New: print(x, end=" ") # Appends a space instead of a newline

    Old: print # Prints a newline
    New: print() # You must call the function!

    Old: print >>sys.stderr, "fatal error"
    New: print("fatal error", file=sys.stderr)

    Old: print (x, y) # prints repr((x, y))
    New: print((x, y)) # Not the same as print(x, y)!
    Bitte verwende die Code-Tags für Codeschnipsel!

    Und die Schreibweise als String ist evlt. schöner anzuschauen:
    Code python:
    1
    2
    
    for buchstabe in "hello world":
      print(buchstabe, end=" ")
    Gruß
     
    If at first you don't succeed, try again. Then quit. No use being a damn fool about it.

  3. #3
    bigfish42 bigfish42 ist offline Grünschnabel
    Registriert seit
    Aug 2011
    Beiträge
    2
    Hallo ,natürlich ist ein string schöner und einfacher,es geht ums debuggen(tracen) der zeile!
    Werd mir mal die Neuerungen genauer ansehen!
     

Ähnliche Themen

  1. Antworten: 4
    Letzter Beitrag: 13.05.11, 15:33
  2. Antworten: 1
    Letzter Beitrag: 27.05.10, 15:44
  3. Antworten: 4
    Letzter Beitrag: 09.11.05, 22:21
  4. Antworten: 2
    Letzter Beitrag: 22.07.05, 12:56
  5. Antworten: 8
    Letzter Beitrag: 07.03.05, 18:20