小编Mid*_*hun的帖子

如何检查列是否包含非数值

我想要获取文件中特定列的非数字记录的计数unix。
我努力了:

awk -F"|" ' $1~ "^[0-9]*$" { print $1 }' File |wc -l

但没有运气。
帮我。

unix awk

2
推荐指数
1
解决办法
5960
查看次数

Python 中不允许使用前导零?

我有一个代码,用于查找列表中给定字符串的可能组合。但是面临前导零获取错误的问题,例如SyntaxError:不允许在十进制整数文字中使用前导零;对八进制整数使用 0o 前缀。如何克服这个问题,因为我想传递带有前导零的值(不能一直手动编辑值)。下面是我的代码

def permute_string(str):
    if len(str) == 0:
        return ['']
    prev_list = permute_string(str[1:len(str)])
    next_list = []
    for i in range(0,len(prev_list)):
        for j in range(0,len(str)):
            new_str = prev_list[i][0:j]+str[0]+prev_list[i][j:len(str)-1]
            if new_str not in next_list:
                next_list.append(new_str)
    return next_list

list = [129, 831 ,014]
length = len(list)
i = 0

# Iterating using while loop
while i < length:
    a = list[i]
    print(permute_string(str(a)))
    i += 1;
Run Code Online (Sandbox Code Playgroud)

python python-3.x

1
推荐指数
2
解决办法
2万
查看次数

标签 统计

awk ×1

python ×1

python-3.x ×1

unix ×1