最简单的方法是什么?
结果应该是:
1: one
2: two
3:
4:
5: five
Run Code Online (Sandbox Code Playgroud)
码:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace TestLines8833
{
class Program
{
static void Main(string[] args)
{
List<string> lines = new List<string>();
lines.Add("");
lines.Add("one");
lines.Add("two");
lines.Add("");
lines.Add("");
lines.Add("five");
lines.Add("");
lines.Add("");
lines.TrimList();
}
}
public static class Helpers
{
public static List<string> TrimList(this List<string> list)
{
//???
}
}
}
Run Code Online (Sandbox Code Playgroud) 我正在尝试根据蛋白质序列创建一个可能的密码子列表.
基本上,我正在尝试创建的脚本将处理给定的字符串输入并输出输入所代表的另一组字符串的可能组合.
例如,字符"F"代表"UUU"或"UUC"; 角色'I'代表'AUU','AUC'或'AUA'.
鉴于输入'FI',我试图创建的脚本应该输出:'UUUAUU','UUUAUC','UUUAUA','UUCAUU','UUCAUC'和'UUCAUA'.
我目前仍然坚持使用此代码:
import itertools
F = ['UUU', 'UUC']
I = ['AUU', 'AUC', 'AUA']
seq, pool = 'FI', []
for i in seq:
pool.append(eval(i))
for n in itertools.product(pool):
print(n)
Run Code Online (Sandbox Code Playgroud)
当我替换pool时itertools.product,它工作pool[0], pool[1].但我无法弄清楚如何使其工作,以便用户可以输入超过2个字符的字符串(即不使其硬编码).
在此先感谢您的帮助!
我有一个我正在写的文件,我无法让file_put_contents在新行上追加下一个条目,即使在换行符之后也是如此.我错过了什么?我在一台Windows机器上.
$file = 'test.txt';
$message = "test\n\n";
file_put_contents($file, $message, FILE_APPEND);
Run Code Online (Sandbox Code Playgroud) 如上所述,我如何在一个单元格中放置2个视图tablerow?我创建了一个表格布局,按代码添加行.
以下是我的代码:
TableLayout v = (TableLayout)inflater.inflate(R.layout.featureitem2, null);
// v.setColumnStretchable(0, true);
//adds each productname to the table
if(productName.size()>1){
TableRow pnamesRow = new TableRow(t);
pnamesRow.addView(new View(t));
for(int j=0;j < productName.size();j++){
LinearLayout wrap = new LinearLayout(t);
LayoutParams params = new TableRow.LayoutParams(TableRow.LayoutParams.FILL_PARENT,TableRow.LayoutParams.FILL_PARENT);
wrap.setLayoutParams(params);
wrap.setOrientation(LinearLayout.HORIZONTAL);
wrap.setVisibility(View.VISIBLE);
ImageView remove = new ImageView(t);
remove.setTag(j);
remove.setClickable(true);
remove.setImageDrawable(t.getResources().getDrawable(R.drawable.remove));
remove.setOnClickListener(new OnClickListener(){
@Override
public void onClick(View arg0) {
int deletePosition = (Integer)arg0.getTag();
Log.v("pos","pos="+deletePosition);
removeChild(deletePosition);
notifyDataSetChanged();
}
});
TextView pname = new TextView(t);
pname.setText(productName.get(j));
pname.setGravity(Gravity.CENTER);
// wrap.addView(pname);
wrap.addView(remove);
wrap.setLayoutParams(params);
pnamesRow.addView(pname); …Run Code Online (Sandbox Code Playgroud) 我有一些大文件可以下载Apache的Http组件,我希望能够在我的网络应用程序的管理控制台中向用户显示一些进度信息.使用此库监视正在进行的下载的正确方法是什么?我将创建一个单例来管理正在进行的下载,我需要的是一种检查开放连接并找出它们在任何给定时间的位置的方法.
我正在寻找一个C#库(不是命令行),商业或免费,其功能类似于FFempeg.视频编码是最重要的.
有什么建议?
最诚挚的问候,符文
为什么这不起作用?innerHTML不能容纳这么复杂的东西吗?
<html>
<head>
<script type="text/javascript">
function addTable() {
var html = "<table><tr><td><label for="name">Name:</label></td><td><input type="text" id="name"></input></td></tr>"; +
"<tr><td><label for="remarks">Remarks:</label></td><td><input type="text" id="remarks"></input></td></tr></table>";
document.getElementById("addtable").innerHTML = html;
}
</script>
</head>
<body>
<input type="submit" value="New Table" onClick="addTable()"/>
<div id="addtable"></div>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
像这样的不那么复杂的东西:
var html = "<table><tr><td>123</td><td>456</td></tr></table>";
Run Code Online (Sandbox Code Playgroud) 我有一个WCF服务的问题,它试图序列化太多的数据.从跟踪中我得到一个错误,该错误表示可以序列化或反序列化的元素的最大数量是'65536',尝试增加MaxItemsInObjectGraph配额.
所以我去修改了这个值,但它被忽略了(错误是相同的,具有相同的数字).这一切都是服务器端的.我暂时通过wget调用该服务.
我的网络配置是这样的:
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior name="AlgoMap.Web.MapService.MapServiceBehavior">
<dataContractSerializer maxItemsInObjectGraph="131072" />
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="false" />
</behavior>
</serviceBehaviors>
</behaviors>
<bindings>
<customBinding>
<binding name="customBinding0" closeTimeout="00:02:00" openTimeout="00:02:00" receiveTimeout="00:02:00">
<binaryMessageEncoding>
<readerQuotas maxDepth="64" maxStringContentLength="16384"
maxArrayLength="16384" maxBytesPerRead="16384"
maxNameTableCharCount="16384" />
</binaryMessageEncoding>
<httpTransport />
</binding>
</customBinding>
</bindings>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" />
<services>
<service behaviorConfiguration="AlgoMap.Web.MapService.MapServiceBehavior"
name="AlgoMap.Web.MapService.MapService">
<endpoint address="" binding="customBinding" bindingConfiguration="customBinding0"
contract="AlgoMap.Web.MapService.MapService" />
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
</service>
</services>
</system.serviceModel>
Run Code Online (Sandbox Code Playgroud)
版本2,不工作:
<system.serviceModel>
<behaviors>
<endpointBehaviors>
<behavior name="AlgoMap.Web.MapService.MapServiceEndpointBehavior">
<dataContractSerializer maxItemsInObjectGraph="131072" />
</behavior>
</endpointBehaviors>
<serviceBehaviors>
<behavior name="AlgoMap.Web.MapService.MapServiceBehavior">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug …Run Code Online (Sandbox Code Playgroud) 我想从命令行运行Zend Framework操作来生成一些文件.这是可能的,我需要对使用ZF的现有Web项目进行多少更改?
谢谢!
在阅读通知的Android指南时,我偶然发现了这个:
增加振动
您可以使用默认振动模式或应用程序定义的振动模式提醒用户.
要使用默认模式,请将"DEFAULT_VIBRATE"添加到默认字段:
Run Code Online (Sandbox Code Playgroud)notification.defaults |= Notification.DEFAULT_VIBRATE;
这样做很清楚:它将DEFAULT_VIBRATE标志添加到通知对象的默认标志.但是|=运营商在Java中做了什么?它看起来像一个"OR",但它是如何工作的?
你能提供一个使用数字的例子吗?
谢谢