SORU
21 Mayıs 2012, PAZARTESİ


Seçime bağlı olarak yüzde (%) Python dizeleri kaçış miyim?

Aşağıdaki kodu var

test = "have it break."
selectiveEscape = "Print percent % in sentence and not %s" % test

print(selectiveEscape)

Çıktıyı almak istiyorum:

Print percent % in sentence and not have it break.

Aslında ne olur:

    selectiveEscape = "Use percent % in sentence and not %s" % test
TypeError: %d format: a number is required, not str

CEVAP
21 Mayıs 2012, PAZARTESİ


>>> test = "have it break."
>>> selectiveEscape = "Print percent %% in sentence and not %s" % test
>>> print selectiveEscape
Print percent % in sentence and not have it break.

Bunu Paylaş:
  • Google+
  • E-Posta
Etiketler:

YORUMLAR

SPONSOR VİDEO

Rastgele Yazarlar

  • edwin maldonado

    edwin maldon

    28 Mart 2009
  • Julian Smith

    Julian Smith

    31 EKİM 2006
  • KittiesMama

    KittiesMama

    10 AĞUSTOS 2008