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

  • adrianisen

    adrianisen

    25 Kasım 2009
  • aki6336

    aki6336

    14 AĞUSTOS 2008
  • MrOctopi

    MrOctopi

    6 Aralık 2010