代码: -
def displayHand(hand):
for letter in hand.keys():
for j in range(hand[letter]):
print letter, # print all on the same line
print # print an empty line
hand = {'a':1, 'q':1, 'l':2, 'm':1, 'u':1, 'i':1}
print displayHand(hand)
输出: -
a i m l l q u
None
需求输出: -
a i m l l q u
请提供合理的解决方案。
答案 0 :(得分:3)
private void IDBox_Click(object sender, EventArgs e)
{
CopyToClipboard((TextBox)sender);
}
private void CopyToClipboard(TextBox textBox)
{
if (textBox.Text != "")
{
textBox.BackColor = System.Drawing.Color.MistyRose;
Clipboard.SetText(textBox.Text);
// set 200ms timeout and then change BackColor
//textBox.BackColor = System.Drawing.SystemColors.Window;
}
}
什么都不返回。只需删除代码末尾的displayHand
即可。
print
输出:
def displayHand(hand):
for letter in hand.keys():
for j in range(hand[letter]):
print letter, # print all on the same line
print # print an empty line
hand = {'a':1, 'q':1, 'l':2, 'm':1, 'u':1, 'i':1}
displayHand(hand)
答案 1 :(得分:1)
当您打印所打印的功能的结果时,您的功能不会return
任何内容None
displayHand(hand) # execute the function without printing the result, in this case None
答案 2 :(得分:1)
displayHand()
函数不返回任何内容,因此当你这样做时 -
print displayHand(hand)
这实际上会打印None
,因为displayHand()
没有返回任何内容。只需在没有print
-
displayHand(hand)