简体   繁体   English

如何在没有括号的情况下打印函数的返回元组

[英]How print the returned tuple of a function without parenthesis

def CountFrequency(z): 
  
    
    freq = {} 
    for item in z: 
        if (item in freq): 
            freq[item] += 1
        else: 
            freq[item] = 1
  
    for key, value in freq.items(): 
        a=(min(freq.values()))
        b=(max(freq.values()))
    return a,b

i want to print my output without brackets but it prints with ( )我想打印不带括号的输出,但打印时带有 ( )

eg -例如——

expected :预期的 :

1 2

output :输出 :

(1,2)

The return type is of tuple type, therefore the parenthesis (it's their string representation).返回类型是元组类型,因此括号(它是它们的字符串表示)。

To print tuple elements separated with spaces you can use the * operator:要打印用空格分隔的元组元素,您可以使用*运算符:

t = a, b = 3, 5

print(*t)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM