이는 단지 내 스니핏 코드:
print("Total score for %s is %s ", name, score)
하지만 난 로렌아줌마가 인쇄하려면 it out:
>. (이름) 는 (점) 점수를 " 총 ";
여기서 '이름' 는 '와' 살충제요 바뀌엇어요 변수 (variable) 은 정수. 이는 전혀 도움이 되는 경우 파이썬 3.3tb.
여러 가지 방법이 있습니다. 현재 사용하여 코드를 통과할 수 있는 튜플 '%'-formatting 해결하십시오 합니다.
보기인쇄 (,) 는 중간합계 " %s 에 대한 %s". % (이름, 살충제요))
한 번의 요소점 looks like a 튜플 (& # 39, this& # 39,) '.'
몇 가지 다른 일반적인 방법으로 하고 있다.
보기인쇄 (" 총 점수를 % % (n), s 는 %hsmb s". % # 39, & # 39, {n&. # 39, & # 39, 이름, s&. 살충제요})
보기인쇄 (", 총 점수를 {}, {} 은 " 스포르마 (이름, 살충제요))
보기인쇄 (", 총 점수를 " 스포르마 (이름, 점), {1} {0} 은 (는)
보기인쇄 (", 총 점수를 {n} 은 (는)}, {s " 스포르마 (n = name, s = 살충제요))
보기인쇄 (" 총 점수를 "; + str (이름) + ". " 있다. + str (사운드트랙)
이 맑고 2, 제 생각에는:
보기인쇄 (,,, 이름, " " 총점을 for" is" 살충제요)
보기인쇄 (, 이름, " " 총 점수를 "; 이 = & # 39, & # 39 점, 9월 ";)
print_function 충스러웠으니 future 가져오기의
보기인쇄 (f& # 39, & # 39 의 {{}} 는 총 살충제요 이름을 살충제요;)
여러 가지 방법으로 인쇄하려면 iqn.
a = 10
b = 20
c = a + b
#Normal string concatenation
print("sum of", a , "and" , b , "is" , c)
#convert variable into str
print("sum of " + str(a) + " and " + str(b) + " is " + str(c))
# if you want to print in tuple way
print("Sum of %s and %s is %s: " %(a,b,c))
#New style string formatting
print("sum of {} and {} is {}".format(a,b,c))
#in case you want to use repr()
print("sum of " + repr(a) + " and " + repr(b) + " is " + repr(c))
EDIT :
#New f-string formatting from Python 3.6:
print(f'Sum of {a} and {b} is {c}')
사용: '스포르마 ()'.
print("Total score for {0} is {1}".format(name, score))
또는:
// Recommended, more readable code
print("Total score for {n} is {s}".format(n=name, s=score))
또는:
print("Total score for" + name + " is " + score)
또는:
`print("Total score for %s is %d" % (name, score))`
그냥 이 준수하십시오
idiot_type = "the biggest idiot"
year = 22
print("I have been {} for {} years ".format(idiot_type, years))
idiot_type = "the biggest idiot"
year = 22
print("I have been %s for %s years."% (idiot_type, year))
'만약' 는 숫자 관심용 살충제요
print("Total score for %s is %d" % (name, score))
점수는 문자열으로 관심용 경우
print("Total score for %s is %s" % (name, score))