turn 相关问题


有没有办法将课堂上的文本转换为可打印的?

当我运行代码时,一切正常,但 str 不适用于类。当我点击运行时,它给我经销商有(, 当我运行代码时,一切正常,但 str 不适用于类。当我单击运行时,它给我经销商有(<main.Card对象位于0x0000020D00046720>,<main.Card对象位于0x0000020D00045850>) 您有 [<main.Card 对象位于 0x0000020D00045A90>、<main.Card 对象位于 0x0000020D00046840>],总共 13 个 选择:1 == 留下,2 == 击中 你能帮我吗?我真的需要你的帮助 import random playerIn = True dealerIn = True class Card: def __init__(self, face): self.face = face def __str__(self): return str(self.face) all_cards = [] for face in [2, 3, 4, 5, 6, 7, 8, 9, 10, 2, 3, 4, 5, 6, 7, 8, 9, 10, 2, 3, 4, 5, 6, 7, 8, 9, 10, 2, 3, 4, 5, 6, 7, 8, 9, 10, 'Jack', 'Queen', 'King', 'Ace', 'Jack', 'Queen', 'King', 'Ace', 'Jack', 'Queen', 'King', 'Ace', 'Jack', 'Queen', 'King', 'Ace']: all_cards.append(Card(face)) playerhand = [] dealerhand = [] def dealcard(turn): card = random.choice(all_cards) turn.append(card) all_cards.remove(card) def total(turn): total = 0 Ace_11 = 0 for card in turn: if card in range(11): total += card elif card in ['King', 'Jack', 'Queen']: total += 10 else: total += 11 Ace_11 += 1 while Ace_11 and total > 21: total -= 10 Ace_11 -= 1 return total def revealdealerhand(): if len(dealerhand) == 2: return dealerhand[0] elif len(dealerhand) > 2: return dealerhand[0], dealerhand[1] for c in range(2): dealcard(dealerhand) dealcard(playerhand) while playerIn or dealerIn: print('Dealer had', revealdealerhand()) print('You have', playerhand, 'for a total of', total(playerhand)) if playerIn: stayORhit = input('Choose: 1 == Stay, 2 == Hit ') if total(dealerhand) > 16: dealerIn = False else: dealcard(dealerhand) if stayORhit == '1': playerIn = False else: dealcard(playerhand) if total(playerhand) >= 21: break elif total(dealerhand) >= 21: break if total(playerhand) == 21: print('You have', playerhand, 'for a total of', total(playerhand), dealerhand, 'for a total of', total(dealerhand)) print("BlackJack! You win! Congarts.") elif total(dealerhand) == 21: print('You have', playerhand, 'for a total of', total(playerhand), dealerhand, 'for a total of', total(dealerhand)) print('BlackJack! Dealer wins!') elif total(playerhand) > 21: print('You have', playerhand, 'for a total of', total(playerhand), dealerhand, 'for a total of', total(dealerhand)) print('You bust! dealer wins!') elif total(dealerhand) > 21: print('You have', playerhand, 'for a total of', total(playerhand), dealerhand, 'for a total of', total(dealerhand)) print('Dealer busts! You win!') elif 21 - total(dealerhand) > 21 - total(playerhand): print('You have', playerhand, 'for a total of', total(playerhand), dealerhand, 'for a total of', total(dealerhand)) print("Dealer busts! You win!") elif 21 - total(dealerhand) < 21 - total(playerhand): print('You have', playerhand, 'for a total of', total(playerhand), dealerhand, 'for a total of', total(dealerhand)) print('You bust! Dealer won!') else: print('You have', playerhand, 'for a total of', total(playerhand), dealerhand, 'for a total of', total(dealerhand)) print('It is a tie!') 您可以覆盖 __repr__ 而不是 __str__: class Card: def __init__(self, face): self.face = face def __repr__(self): return str(self.face)


修改现有的.htaccess,使其忽略子域

我有以下 .htaccess 文件,虽然我知道它远非最佳(并且可能有点令人畏惧) - 它只是有效。 # 防止公众查看 .htaccess 文件 我有以下 .htaccess 文件,虽然我知道它远非最佳(而且可能有点令人难受) - 它只是有效。 # Prevents public viewing of .htaccess file <Files .htaccess> order allow,deny deny from all </Files> # Custom 404 page ErrorDocument 404 https://www.domain.com/404/ # Turn on rewriting and set rewriting base RewriteEngine On RewriteBase / # Force WWW RewriteCond %{HTTP_HOST} !^$ RewriteCond %{HTTP_HOST} ^([^.]+)\.([a-z]{2,4})$ [NC] RewriteCond %{HTTPS}s ^on(s)| RewriteRule ^ http%1://www.%{HTTP_HOST}%{REQUEST_URI} [R=302,L] # Force WWW and HTTPS RewriteCond %{HTTP_HOST} !^www\. [NC,OR] RewriteCond %{HTTPS} off RewriteRule ^ https://www.domain.com%{REQUEST_URI} [R=301,L] # Remove .php extension RewriteRule ^(properties)/(all|location1|location2|location3)/(all|1|2|3|4|5|6|7|8|9)/(asc|desc) $1.php?location=$2&bedrooms=$3&sort-by=$4 RewriteRule ^(properties)/(all|location1|location2|location3)/(all|1|2|3|4|5|6|7|8|9) $1.php?location=$2&bedrooms=$3 RewriteRule ^(properties)/(all|location1|location2|location3) $1.php?location=$2 RewriteRule ^(view-property)/(.*)/(print-view) $1.php?id=$2&print=true RewriteRule ^(view-property)/(.*)/ $1.php?id=$2 RewriteRule ^(.*)/$ $1.php 我们的新网站现已准备好推送到我们新创建的临时环境中进行测试。在本例中,它会是 staging.domain.com,但我们在实际访问此暂存 URL 时遇到问题。 编辑 - 只是为了澄清,问题是访问 staging.domain.com 重定向到 https://www.domain.com。 我们认为问题是由我们上面的重写规则引起的。我研究了一些可能的解决方案,包括向现有重写规则添加附加条件,例如: RewriteCond %{HTTP_HOST} !^staging\.domain\.com 或添加新的条件/规则,例如: RewriteCond %{HTTP_HOST} ^staging\.domain\.com [NC] RewriteRule ^(.*) - [L] 但不幸的是这些都不起作用。使用 .htaccess 文件确实不是我的强项,所以如果有人可以提供任何帮助,那就太好了。 附注新网站由 Laravel 5.3 提供支持,因此当我们上线时,我将摆脱重写规则(位于底部的规则)的可怕尝试! 您的顶级规则必须更改为此以删除目标 URL 中的硬编码域名: # Turn on rewriting and set rewriting base RewriteEngine On RewriteBase / # Force WWW and HTTPS RewriteCond %{HTTP_HOST} !^www\. [NC,OR] RewriteCond %{HTTPS} off RewriteCond %{HTTP_HOST} ^(?:www\.)?(.+)$ [NC] RewriteRule ^ https://www.%1%{REQUEST_URI} [R=301,L,NE] # Remove .php extension and rest of the rewrite rules Crypto.com 登录问题 已经是 crypto.com 登录用户?继续作为 crypto.com 登录问题用户。或者。电子邮件。密码。登录 忘记密码?没有帐户?立即注册。注册 Crypto.com NFT 帐户 · 连接您经过验证的 crypto.com 登录问题 · 提交申请成为创建者 Trezor suite 应用程序 移动版 Trezor Suite Lite 是一款免费应用程序,可让您同步和跟踪所有比特币和加密货币您手机上的帐户。适用于 Trezor 硬件钱包的新桌面和浏览器应用程序。 Trezor Suite 在可用性、安全性和隐私这三个关键支柱上带来了重大改进。


© www.soinside.com 2019 - 2024. All rights reserved.