我编写的代码只是创建一个结构并将其打印成多行 如何创建一个包含所有行的字符串
import pyperclip
symbol = input('Symbol = ')
width = int(input('Width = '))
height = int(input('Height = '))
while height > 0:
print(symbol * width)
height = height - 1
print('\nCopy to Clipboard ?\nY For Yes\nN For No\n')
sel = input('')
if sel == 'Y':
pyperclip.copy('Here i want to copy the Structure')
elif sel == 'N':
print('Done')
答案 0 :(得分:0)
您可以使用f字符串和加法。
public IServiceProvider ConfigureServices(IServiceCollection services)
{
//...
// Some DIs in ConfigureService
services.AddTransient<ICustomService, CustomService>(); //this should be passed later to handler
services.AddHttpContextAccessor();
//...
// Adding authentication in ConfigureServices
services.AddAuthentication("Basic")
.AddScheme<CustomBasicAuthenticationOptions, CustomBasicAuthenticationHandler>("Basic", null);
//...
}
这将产生与您的代码相同的输出,但是这次您具有唯一的字符串。
答案 1 :(得分:0)
您可以使用列表推导来构建字符串,然后一次使用所有字符串
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
<item >
<rotate
android:fromDegrees="45"
android:toDegrees="-45"
android:pivotX="15%"
android:pivotY="-36%" >
<shape
android:shape="rectangle" >
<padding
android:bottom="50dp"
android:left="0dp"
android:right="0dp"
android:top="0dp" />
<gradient
android:angle="225"
android:endColor="@android:color/transparent"
android:centerColor="@android:color/transparent"
android:startColor="#999999"
android:centerY="0.1"
android:type="linear" />
</shape>
</rotate>
</item>
</layer-list>