实际上有2个问题
1)在所选行上切换评论的快捷方式?适用于我用notepad ++开始使用的所有iDE
2)ctrl-k, ctrl-c展品的这种行为(引自某个地方措辞得很好):
C#:选择某些文本的每一行都在line-start上用双斜杠进行注释.如果未选择任何内容,则注释光标所在的行.
C++:如果未选择任何内容或选择完整行,则其行为与上述相同.但是,如果选择了部分行,并且未选择任何注释作为选择的一部分(例如,选择代码行中间的某些内容),则选择将被/*和*/包围.
因为我在C++中编码,我发现这种行为很烦人 - 我希望能够注释掉部分选中的行 - 任何变通方法?
我是android的新手.
我想在广播接收器中获得GPS定位,但它显示错误.
我的代码是:
public void onReceive(Context context, Intent intent) {
LocationManager locManager = (LocationManager)
getSystemService(Context.LOCATION_SERVICE);
// errors in getSystemService method
LocationListener locListener = new MyLocationListener();
locManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0,
locListener);
Location loc = locManager
.getLastKnownLocation(LocationManager.GPS_PROVIDER);
Log.d(" **location**", " location" + loc.getLatitude());
}
Run Code Online (Sandbox Code Playgroud)
问题:
我想找到一个Android项目的当前位置.加载应用程序时,我的当前位置始终为null.我已经在清单等中设置了权限.当我找到当前位置时,我打算使用坐标来查找到地图上其他位置的距离.我的代码片段如下.为什么我总是得到一个空值?
locMan = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
Criteria crit = new Criteria();
towers = locMan.getBestProvider(crit, false);
location = locMan.getLastKnownLocation(towers);
if (location != null) {
System.out.println("Location is not null!");
lat = (int) (location.getLatitude() *1E6);
longi = (int) (location.getLongitude() * 1E6);
GeoPoint ourLocation = new GeoPoint(lati, longi);
OverlayItem overlayItem = new OverlayItem(ourLocation, "1st String",
"2nd String");
CustomPinpoint custom = new CustomPinpoint(d, MainMap.this);
custom.insertPinpoint(overlayItem);
overlayList.add(custom);
overlayList.clear();
} else {
System.out.println("Location is null! " + towers);
Toast.makeText(MainMap.this, "Couldn't get provider",Toast.LENGTH_SHORT)
.show();
}
Run Code Online (Sandbox Code Playgroud) 这个问题是关于良好的编程实践和避免潜在的漏洞.
我读了Joshua Bloch的Effective Java,这就是我想知道的:
为什么我要考虑在我的不可变类中使用getter方法制作防御性副本而不使用mutator?
第二:除了私人之外,我为什么要让我的领域最终成绩?这只是关于性能(不是安全性)吗?
首先,这是我的测试代码,我使用的是python 3.2.x:
class account:
def __init__(self):
pass
class bank:
def __init__(self):
self.balance = 100000
def balance(self):
self.balance
def whitdraw(self, amount):
self.balance -= amount
def deposit(self, amount):
self.balance += amount
Run Code Online (Sandbox Code Playgroud)
当我做:
a = account()
a.bank.balance
Run Code Online (Sandbox Code Playgroud)
我希望得到平衡值的回报,而不是我得到的功能"平衡",为什么会这样?我这样做时会返回余额值:
class bank:
def __init__(self):
self.balance = 100000
def balance(self):
self.balance
def whitdraw(self, amount):
self.balance -= amount
def deposit(self, amount):
self.balance += amount
a = bank()
a.balance
Run Code Online (Sandbox Code Playgroud)
所以我想知道为什么会这样,如果有人想出办法让我在嵌套版本中获得平衡价值,那就太棒了.
如果有任何未读的短信然后将其发送到我的网站,然后将其标记为读取以将数据发布到我使用asynctask的网站,我想制作一个每隔20秒检查一次我的短信的服务,当我手动尝试时(通过制作)它工作正常按钮点击类型应用程序)但在侧面服务我不能定义
runOnUiThread(new Runnable() {
@Override
public void run() { new MyAsyncTask().execute(sender,time,message);}
});
Run Code Online (Sandbox Code Playgroud)
它无法识别并要求我定义runOnUiThread有没有办法从我在下面代码中调用的地方调用我的asynctask
public class TestService extends Service {
String sender = null;
String time = null;
String message = null;
@Override
public IBinder onBind(Intent intent) {
// TODO: Return the communication channel to the service.
throw new UnsupportedOperationException("Not yet implemented");
}
@Override
public void onCreate() {
Toast.makeText(getApplicationContext(), "Service Created", 1).show();
super.onCreate();
}
@Override
public void onDestroy() {
Toast.makeText(getApplicationContext(), "Service Destroy", 1).show();
super.onDestroy();
}
@Override
public int onStartCommand(Intent intent, int …Run Code Online (Sandbox Code Playgroud) 任何人都可以解释为什么loc在python pandas中使用的例子如下所示?
for i in range(0, 2):
for j in range(0, 3):
df.loc[(df.Age.isnull()) & (df.Gender == i) & (df.Pclass == j+1),
'AgeFill'] = median_ages[i,j]
Run Code Online (Sandbox Code Playgroud) 在Eclipse下开发Java应用程序时,我收到了关于"通过合成方法访问的方法/值"的警告.解决方案只是将私有访问修饰符更改为默认级别.
这让我想知道:使用合成方法的惩罚是什么?有一些?我假设编译器/ Eclipse会引发警告,但它是如此相关的东西还是可以安全忽略的东西?
我没有在这里看到这些信息,所以我问.
不知怎的,我的旧问题已经关闭,所以我开了一个新问题:
我正在使用Java Generics从SQL查询中实现通用双向哈希映射.它应该能够来回映射String,Integer对的任意组合.它应该像这样使用:
String sql = "SELECT string_val, int_val FROM map_table";
PickMap<String, Integer> pm1 = new PickMap<String, Integer>(sql);
String key1 = "seven";
Integer value1 = pm1.getLeft2Right(key1);
Integer key2 = 7;
String value2 = pm1.getRightToLeft(key2);
Run Code Online (Sandbox Code Playgroud)
当然应该可以创建一个pm(整数,整数)等等......
我对Pick Map的实现看起来像这样(没有getter ...):
public class PickMap<L, R> {
private final HashMap<L, R> left2Right = new HashMap<L, R>();
private final HashMap<R, L> right2Left = new HashMap<R, L>();
public PickMap(String sql) throws OException {
DTable d = new DTable(sql);
int colTypeL = d.t.getColType(1);
int colTypeR = d.t.getColType(2); …Run Code Online (Sandbox Code Playgroud) 当我读取文件时,tf.read_file我得到了类型的东西tf.string.文档只说它是"可变长度字节数组.Tensor的每个元素都是一个字节数组." (https://www.tensorflow.org/versions/r0.10/resources/dims_types.html).我不知道如何解释这个.
我对这种类型无能为力.在通常的python中你可以通过索引获取元素my_string[:4],但是当我运行以下代码时,我得到一个错误.
import tensorflow as tf
import numpy as np
x = tf.constant("This is string")
y = x[:4]
init = tf.initialize_all_variables()
sess = tf.Session()
sess.run(init)
result = sess.run(y)
print result
Run Code Online (Sandbox Code Playgroud)
它说
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/framework/tensor_shape.py", line 621, in assert_has_rank
raise ValueError("Shape %s must have rank %d" % (self, rank))
ValueError: Shape () must have rank 1
我也无法将我的字符串转换为tf.float32张量.它是.flo文件,它有魔术标题"PIEH".这个numpy代码成功地将这样的头转换为数字(参见这里的例子/sf/answers/1961152861/)但我不能用tensorflow做到这一点.我试过tf.string_to_number(string, out_type=tf.float32)但它说
tensorflow.python.framework.errors.InvalidArgumentError: StringToNumberOp could not correctly convert string: …