TypeError: unsupported operand type(s) for %: 'NoneType' and 'tuple'TypeError: desteklenmeyen işlenen türü (ler) için%: 'NoneType' ve 'tuple' rasgele oluşturucu ile?
%s
yerine yazdırmak için bir alıntıya veya resme ihtiyacım var, ancak nasıl olduğunu anlayamıyorum?
#!/usr/bin/python
import random
if __name__=="__main__":
print("Content-type: text/html")
print()
quotes=["The course of true love never did run smooth.", "Life every man holds dear; but the dear man holds honor far more precious dear than life.",
"To thine own self be true, and it must follow, as the night the day, thou canst not then be false to any man.", "Poor and content is rich, and rich enough.",
"If you have tears, prepare to shed them now.", "Words without thoughts never to heaven go."]
pics=["https://ebooks.adelaide.edu.au/s/shakespeare/william/portrait.jpg", "http://images.wisegeek.com/william-shakespeare-painting.jpg",
"https://mareseosullivan.files.wordpress.com/2012/01/william-shakespeare.jpg", "http://bookhaven.stanford.edu/wp-content/uploads/2010/10/shakespeare-4.jpg",
"http://i.telegraph.co.uk/multimedia/archive/02699/shakespeare_2699766b.jpg", "http://www.poetryfoundation.org/uploads/authors/william-shakespeare/448x/william-shakespeare.jpg"]
print ("""
<html>
<head>
<title>QOTD: Shakespeare </title>
</head>
<body>
<center>
<img src="%s">
<p>
<font size="12"><b>The quote of the day is:</b></font>
<p>
<table>
<tr>
<td width="500"><font size="6">%s</font>
</td>
</tr>
</table>
</p>
</center>
</body>
</html>
""") % (random.choice(pics), random.choice(quotes))
Ben girinti değiştirmek zorunda @idjaw Sorguda doğru şekilde basılacak kodu almak için buraya tıklayın. Ne değiştiğini bana bildirir misin? –
Kodunuzu Python 2.7'de çalıştırdım. Python 3'ü çalıştırdığımda sorununuzu çoğaltdım. Bununla birlikte, kodunuzun doğru bir şekilde gösterilmesi için sorgunuzdaki girintinizi gerçekten düzeltmeniz gerekir. – idjaw