我是新的tcl用户。
我正在尝试为输出文件键入空格。
我正在使用lappend
命令:
lappend lineM1 [ format "%-4s" " " ]
set outfile [open "test" w]
puts $outfile "$lineM1"
close $outfile
这就是我得到的:
{ }
如何删除括号?如何仅打印空格?
答案 0 :(得分:2)
我不确定你想做什么,但如果你更换了
lappend
set lineM1
list
。你没有得到括号。
tcl命令lappend是format "%-4s" " "
命令。它会将lineM1
的结果附加到尚未存在的列表$outfile
。
顺便说一下,如果您只是想在format
中打印空白区域,则不需要set foo "bar"
puts $foo
该空白区域。也许你应该看一下format manual page。
示例:
bar
将导致:
$outfile
在您的情况下,您会将文件句柄puts
添加到puts $outfile $foo
来电:
String serviceAccountEmail = "3512650851-4tpr9073rju4deqtfjp210j07q52hu2j@developer.gserviceaccount.com";
var certificate = new X509Certificate2(@"My Project-d3e5dda28438.p12", "notasecret", X509KeyStorageFlags.Exportable);
ServiceAccountCredential credential = new ServiceAccountCredential(
new ServiceAccountCredential.Initializer(serviceAccountEmail)
{
User = "<UserEmail for which to download message>",
Scopes = new[] { GmailService.Scope.GmailCompose, GmailService.Scope.GmailModify }
}.FromCertificate(certificate));
var gmailservice = new Google.Apis.Gmail.v1.GmailService(new BaseClientService.Initializer()
{
HttpClientInitializer = credential,
ApplicationName = "MyNewProject",
});
try
{
ListMessagesResponse messages = gmailservice.Users.Messages.List("<User Email>").Execute();
IList<Google.Apis.Gmail.v1.Data.Thread> threads = gmailservice.Users.Threads.List("<User Email>").Execute().Threads;
List<Message> responsemessages = new List<Message>();
responsemessages.AddRange(messages.Messages);
foreach(Message msg in responsemessages)
{
Google.Apis.Gmail.v1.UsersResource.MessagesResource.GetRequest gr = gmailservice.Users.Messages.Get("<User Email>", msg.Id);
gr.Format = Google.Apis.Gmail.v1.UsersResource.MessagesResource.GetRequest.FormatEnum.Full;
Message m = gr.Execute();
if (gr.Format == Google.Apis.Gmail.v1.UsersResource.MessagesResource.GetRequest.FormatEnum.Raw)
{
byte[] decodedByte = FromBase64ForUrlString(m.Raw);
string base64Encoded = Convert.ToString(decodedByte);
MailMessage msg2 = new MailMessage();
//msg2.LoadMessage(decodedByte);
}
}
}
catch (Exception ex) { }
tcl.tk wiki对于初学者来说是一个很好的资源。