python - 为什么我有 python 错误 unindent does not match any external indentation level 错误
问题描述
from TikTokApi import TikTokApi
import time
import os
import random
api = TikTokApi()
def getLikeCount():
tiktoks = api.byUsername('user', count=1)
for tiktok in tiktoks:
likeCount = tiktok["stats"]["diggCount"]
shareCount = tiktok["stats"]["shareCount"]
commentCount = tiktok["stats"]["commentcount"]
followCount = tiktok["authorStats"]["followerCount"]
return (likeCount,shareCount,commentCount,followCount)
def fag():
os.system("afplay -/desktop/tiktok/fag.mp3 ")
def update():
initLikeCount = 0
while True:
results = getLikeCount()
currentNumLikes = results[0]
print("sleep time")
time.sleep(5)
if currentNumLikes > initLikeCount:
newLikes = currentNumLikes - initLikeCount
initLikeCount = currentNumLikes
print("new like count = ",newLikes)
for x in range(newLikes):
print("now playing this Fag.mp3",x)
time.sleep(random.randint(0,3))
fag()
else()
print("no new likes ):")
update()
#getLikeCount()
为什么会发生这种情况,我正在制作一个 tiktok 机器人,每次我得到一个喜欢时,我都会发出声音(顺便说一句,我在 ubuntu 上,但这也发生在 Windows 上)
解决方案
声明与声明else
不一致if
。
顺便说一句,下次使用 ctrl-K 在 StackOverflow 中对齐您的代码。
推荐阅读
- reactjs - 如何将 Gutenberg ColourPicker RGBA 存储为元数据(React)
- go - 如何在 GoLang 中解析 url 中的多个参数?
- inventory - Odoo 13:如何为同一产品使用每家公司的不同重量计量单位
- ssl - 如果我在具有备用信任路径的链中的其他证书已过期,会发生什么情况?
- c# - 如何解决硒 C# 中 Chrome 驱动程序中的“错误:browser_switcher_service.cc”XXX Init() 问题
- ios - SwiftPM 迁移后未找到 Realm.Sync* 类
- c# - 如何制作不会覆盖 WPF .XAML 中样式的自定义文本框
- android - Android - “firebase.test.lab”设置无法从 Firebase 分析中排除 Play 商店测试活动
- jenkins - 如何在 Jenkins 中使用 kubeconfig 文件作为凭证?
- python - 使用 enumerate() 时一次读取两行